package factory.simplefactory;

//图形工厂
public class GraphicalFactory {
    //工厂保证是单例的
    private static GraphicalFactory graphicalFactory = new GraphicalFactory();

    private GraphicalFactory() {
    }//私有化构造方法

    private Graphical graphical;

    public Graphical getGraphical(String name) {
        if (name.equals("圆形")) {
            this.graphical = new Crcular();
        }
        if (name.equals("方形")) {
            this.graphical = new Square();
        }
        if (name.equals("三角形")) {
            this.graphical = new Triangle();
        }
        return this.graphical;
    }
    //提供对外方法获取本工厂
    public static GraphicalFactory getGraphicalFactory() {
        return graphicalFactory;
    }
}
